import java.util.Scanner;
public class Main {

    public static void main1(String[] args) {

  /*      Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()) {
            int n = sc.nextInt();
            for(int i = 0 ; i < n ; i++) {
                for(int j = 0 ; j < n ; j++) {
                    if(i == j || i + j == n-1) {
                        System.out.print("*");
                    } else {
                        System.out.print(" ");
                    }
                }
                System.out.println();
            }
        }*/

        /*int n =0;
        Scanner scan = new Scanner(System.in);
        n = scan.nextInt();
        while(n != 0){
            System.out.println(n % 10);
            n /= 10;
        }*/

    }

//        public static void main2(String[] args) {
//
//            String password = "123456";
//            Scanner scan = new Scanner(System.in);
//            System.out.println("请输入密码：");
//            int retrytime = 3;
//
//            //3次
//            for (int i = 0; i < 3; i++) {
//                String input = scan.nextLine();
//                if (input.equals(password)) {
//                    System.out.println("输入正确！");
//                    break;
//                }
//                else {
//                    retrytime--;
//                    System.out.println("输入错误，请重新输入,还有" + retrytime + "次机会");
//                }
//            }
//            //输入错误三次
//            if (retrytime == 0) {
//                System.out.println("输入次数用完，退出程序");
//            }
//        }
    public static void main3(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();

        System.out.print("奇数位:");
        for (int i = 31; i >= 1; i -= 2) {
            System.out.print((num >> i) & 1);
        }
        System.out.print("偶数位:");
        for (int i = 30; i >= 0 ; i -= 2) {
            System.out.print((num >> i) & 1);
        }
    }

    public static void main(String[] args) {
        int a = 0;
        int b = 0;
        Scanner scan = new Scanner(System.in);
        a = scan.nextInt();
        b = scan.nextInt();
        int m = (Math.max(a, b));
        int n = (Math.min(a, b));
        while((m % n) != 0){
            int c = m % n;
            m = n;
            n = c;
        }
        System.out.println("最大公约数是"+n);
    }
}
